source configXML.tcl
source testXML.tcl
source tester.tcl
source sender.tcl
source logfile.tcl
source adaptor.tcl
package require Expect
global expect_out buffer
set buffer ""
set expect_out(buffer) ""
set results ""

proc exit_process { } {
	global results
	global expect_out buffer
	set results $buffer
}

proc connect {password } {
	global expect_out buffer
	set timeout 60
	send "$password\r"
	send "enable\r"
	send "$password\r"
	expect "#"
	append buffer $expect_out(buffer)
}

proc quit { } {
	send " exit\r"
}

set results $buffer
initXml "resource/config.xml"
inittable
set count [getEquipNumber]
for {set i 0} {$i < $count} {incr i} {
	openLog ./log/confige_$i.log
		set connectInfo [getConnectorInfo $i]
		set ip [dict get $connectInfo ip]
		set name [dict get $connectInfo name]
		set pwd [dict get $connectInfo pwd]
		spawn telnet $ip
		connect CISCO
		set portInfo [getConfInfo $i]  
		set protocolInfo [getProtocolInfo $i]
		dict set equipmentInfo portInfo $portInfo 
		dict set equipmentInfo protocolInfo $protocolInfo
	        ParserController $equipmentInfo
	set results $buffer
	set buffer ""
	writeLog $results
	closeLog
	}

set count [getTestNumber]
for {set i 0} {$i < $count} {incr i} {
	openLog ./TestResults/test_$i.log
		set commands [getTestCommands $i]
		set cid [dict get $commands id]
		set connectInfo [getConnectorInfo $cid]
		set ip [dict get $connectInfo ip]
		set name [dict get $connectInfo name]
		set pwd [dict get $connectInfo pwd]
		spawn telnet $ip
		connect CISCO
		testController $commands
	set results $buffer
	set buffer ""
	writeLog $results
	closeLog
	}
exit_process